<admintpl file="header" />
<style type="text/css">
.pic-list li {
	margin-bottom: 5px;
}
</style>
<script type="text/javascript">
    $(document).ready(function () {
        $("#select_driver_name").quicksearch(".driver_id_list li", {
            noResults: '.no_driver_id',
            loader: 'span.loading'
        });
        $("#select_card_number").quicksearch(".card_number_list li", {
            noResults: '.no_card_number_list',
            loader: 'span.loading'
        });

    });
    function change_lid(){
        var lid = $("#lid").val();
        location.href="{:U('AdminCar/add',array('id'=>empty($item['id'])?'':$item['id']))}&lid="+lid;
    }
</script>
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:U('AdminCar/index')}">车辆信息</a></li>
			<li class="active"><a href="{:U('AdminCar/add',array('id'=>empty($item['id'])?'':$item['id']))}" target="_self">添加车辆</a></li>
		</ul>
		<form action="{:U('AdminCar/add_post')}" method="post" class="form-horizontal js-ajax-forms" enctype="multipart/form-data" onsubmit="return checkform();">
			<div class="row-fluid">
				<div class="span9">
					<table class="table table-bordered">
                        <if condition="$is_manager">
                            <tr>
                                <th>物流公司<span class="form-required">*</span></th>
                                <td>
                                    <select name="lid" id="lid" onchange="change_lid();">
                                        <foreach name="logistics_list" item="vo">
                                            <option value="{$vo.id}" <if condition="$vo['id'] == $lid">selected</if>>{$vo.logistics_name}</option>
                                        </foreach>
                                    </select>
                                </td>
                            </tr>
                        </if>

						<tr>
							<th>车牌号码<span class="form-required">*</span></th>
							<td><input type="text" class="require" name="car_code" id="car_code" value="{$item.car_code}" style="width: 400px" placeholder="请输入车牌号码"> </td>
						</tr>
                        <tr>
                            <th>行驶本号码<span class="form-required">*</span></th>
                            <td><input type="text" class="require" name="car_licence" id="car_licence" value="{$item.car_licence}" style="width: 400px" placeholder="请输入行驶本号码"> </td>
                        </tr>
                        <tr>
                            <th>车主姓名<span class="form-required">*</span></th>
                            <td><input type="text" class="require" name="car_master" id="car_master" value="{$item.car_master}" style="width: 400px" placeholder="请输入车主姓名"> </td>
                        </tr>
                        <tr>
                            <th>保险日期<span class="form-required">*</span></th>
                            <td><input type="text" name="car_insurance" id="car_insurance" value="<if condition="empty($item['car_insurance'])">{:date('Y-m-d',time())}<else/>{$item.car_insurance}</if>" class="js-date require" style="width: 400px" > </td>

                        </tr>
                        <tr>
                            <th>上牌日期 <span class="form-required">*</span></th>
                            <td>
                                <input type="text" name="car_regist_time" id="car_regist_time" value="<if condition="empty($item['car_regist_time'])">{:date('Y-m-d',time())}<else/>{$item.car_regist_time}</if>" class="js-date require" style="width: 400px" > </td>
                        </tr>
                        <tr>
                            <th>车管所绑定手机号<span class="form-required">*</span></th>
                            <td><input type="text" class="require phone" name="car_mobile" id="car_mobile" value="{$item.car_mobile}" style="width: 400px" placeholder="请输入车管所绑定手机号"> </td>
                        </tr>
                        <tr>
                            <th>车辆照片<span class="form-required">*</span></th>
                            <td>
                                <input type="hidden"  class="require" name="car_photo" id="car_photo" value="{$item.car_photo}">
                                <div style="text-align: left;">
                                    <a href="javascript:upload_one_image('图片上传','#car_photo');">
                                        <if condition="empty($item['car_photo'])">
                                            <img src="__TMPL__Public/assets/images/default-thumbnail.png" id="car_photo-preview" width="135" style="cursor: hand"/>
                                            <else />
                                            <img src="{:sp_get_image_preview_url($item['car_photo'])}" id="car_photo-preview" width="135" style="cursor: hand"/>
                                        </if>
                                    </a>
                                    <input type="button" class="btn btn-small" onclick="$('#car_photo-preview').attr('src','__TMPL__Public/assets/images/default-thumbnail.png');$('#car_photo').val('');return false;" value="取消图片">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <th>绑定驾驶员<span class="form-required">*</span></th>
                            <td>
                                <input type="text"  name="driver_name" id="driver_name" value="{$item['driver_name']}" readonly style="width: 400px" placeholder="选择驾驶员">
                                <input type="hidden" class="require" name="driver_id" value="{$item['driver_id']}" id="driver_id"/>
                                <!--<span class="loading">搜索中。。</span>-->
                                <div class="div_quicksearch driver_id_list">
                                    <input type="text" name="select_driver_name" id="select_driver_name" value="" placeholder="请输入绑定驾驶员"/>
                                    <ul class="quicksearch">
                                        <foreach name="driver_list" item="ditem">
                                            <li  onclick="quick_select('driver_name','{$ditem.driver_name}','driver_id','{$ditem.id}')">{$ditem.driver_name}</li>
                                        </foreach>
                                        <li class="no_driver_id">没找到数据</li>
                                    </ul>
                                </div>

                            </td>
                        </tr>
                        <tr>
                            <th>绑定会员卡<span class="form-required">*</span></th>
                            <td><input type="text" name="card_number" id="card_number" value="{$item['card_number']}"  value="" style="width: 400px" readonly placeholder="选择会员卡">
                                <input type="hidden" class="require" name="card_id" value="{$item['card_id']}" id="card_id" value=""/>

                                <div class="div_quicksearch card_number_list">
                                    <input type="text" name="select_card_number" id="select_card_number" value="" placeholder="请输入绑定会员卡号"/>
                                    <ul class="quicksearch">
                                        <foreach name="card_list" item="citem">
                                            <li  onclick="quick_select('card_number','{$citem.number}','card_id','{$citem.id}')">{$citem.number}</li>
                                        </foreach>
                                        <li class="no_card_number">没找到数据</li>
                                    </ul>
                                </div>
                            </td>
                        </tr>

                    </table>
				</div>

			</div>
			<div class="form-actions">
                <input type="hidden" name="id" value="{$item.id}"/>
				<button class="btn btn-primary js-ajax-submit" type="submit">提交</button>
				<a class="btn" href="{:U('AdminCar/index')}">返回</a>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="__PUBLIC__/js/common.js?5"></script>
<script>
    $(function(){
        $("#driver_name,#select_driver_name").click(function(){
            event.stopPropagation();
            $('.driver_id_list').show();
            return false;
        });
        $("#card_number,#select_card_number").click(function(){
            event.stopPropagation();
            $('.card_number_list').show();
            return false;
        });
        $("body").click(function(){
            $(".div_quicksearch").hide();
        });
    });

    function quick_select(id,val,id2,val2){
        $("#"+id).val(val);
        $("#"+id2).val(val2);
    }

</script>
	</body>
</html>